<?php
include('../../inc/global.inc');
include("../islogin.php");
$url="pinpai.php";
$thepage=$_GET['page']?$_GET['page']:1;
$maxpage=20;
?>
<?php
//删除信息
if($_GET['del_act']){
$urls=$_SERVER['HTTP_REFERER'];
@mysql_query("delete from jm_list  where id='".$_GET['del_id']."'");
echo "<script>location='".$urls."';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
  <table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">品牌与推荐列表&nbsp;&nbsp;<a href="javascript:history.go(-1)">Back</a></td>
    </tr>
  </table>
  <table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <form method="get" action="" name="form1">
      <tr>
        <td height="25" bgcolor="#EEEEF9" style="padding:5px;line-height:25px;"><strong>高级搜索:</strong>（账号，名称）
          <input name="search_name" type="text" size="30">
          <input name="submit" type="submit" value="搜索">
        </td>
      </tr>
    </form>
  </table>
  <table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td width="4%" height="30" align="center" bgcolor="#8DA8CF">编号</td>
      <td width="8%" align="center" bgcolor="#8DA8CF">图片</td>
      <td width="32%" align="center" bgcolor="#8DA8CF">名称</td>
      <td width="15%" align="center" bgcolor="#8DA8CF">分类</td>
      <td width="10%" align="center" bgcolor="#8DA8CF">会员账号</td>
      <td width="20%" align="center" bgcolor="#8DA8CF">城市</td>
      <td width="10%" align="center" bgcolor="#8DA8CF"><a href="pinpai_modify.php?tj_act=ok">添加</a></td>
    </tr>
<?php
if($_GET[search_name]){
$search_sql=" and (jm_pinpai.j_title like '%$_GET[search_name]%' or member.m_user like '%$_GET[search_name]%')";
}
if($_GET[search_id]){
$search_sql=" and (jm_pinpai.id='$_GET[search_id]')";
}
$sql="select jm_pinpai.id,jm_pinpai.type_id,jm_pinpai.picture,jm_pinpai.j_title,jm_pinpai.member_id,member.m_user,member.city from jm_pinpai inner join  member on (jm_pinpai.member_id=member.id) where 1=1 ".$search_sql." order by jm_pinpai.id desc limit ".($thepage-1)*$maxpage.",$maxpage";

$rs=@mysql_query($sql);
$i=1;
while($row=@mysql_fetch_array($rs)){
$color=($i%2)?"#FFFFFF":"#eeeeee";
?>
    <tr bgcolor=<?=$color?>>
      <td height="25" align="center"><?=$i?></td>
	  <td height="25" align="center"><?php if($row[picture]){?><img src="http://www.sandib2b.cn/upfile/<?=$row[picture]?>" width="40" height="40" border="0" /><?php }?></td>
	  <td align="left" style="padding-left:5px;"><?=$row[j_title]?></td>
	  <td align="center"><?php if($row[type_id]==1){echo "推荐";}else{echo "品牌";}?></td>
	  <td align="center"><?=$row['m_user']?></td>
	  <td align="center"><?=$row['city']?>
      
	  <td align="center"><a href="pinpai_modify.php?xg_act=ok&xg_id=<?=$row['id']?>">编辑</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="<?=$url?>?del_act=ok&del_id=<?=$row['id']?>" onClick="return del()">删除</a></td>
    </tr>
<?php
$i++;}
//分页参数
$rs2=@mysql_query("select count(jm_pinpai.id) from jm_pinpai inner join  member on (jm_pinpai.member_id=member.id) where 1=1 ".$search_sql);
$totalrecord=@mysql_result($rs2,0);
$totalpage=ceil($totalrecord/$maxpage);
@mysql_free_result($rs2);
?>
<tr><form method="get" action="<?=$url?>?search_name=<?=$_GET[search_name]?>">
   <td height="25" colspan="7" align="center" bgcolor="#FFFFFF">
<?php if($thepage>1){?>
   <a href="<?=$url?>?search_name=<?=$_GET[search_name]?>">第一页</a>&nbsp;<a href="<?=$url?>?page=<?=$thepage-1?>&search_name=<?=$_GET[search_name]?>">上一页</a>&nbsp;
<?php }?>  
<?php if($thepage!=$totalpage&&$totalpage>0){?>
   <a href="<?=$url?>?page=<?=$thepage+1?>&search_name=<?=$_GET[search_name]?>">下一页</a>&nbsp;<a href="<?=$url?>?page=<?=$totalpage?>&search_name=<?=$_GET[search_name]?>">最后一页</a>&nbsp;
<?php }?>   
   【共<font color="red"><?=$totalrecord?></font>条记录】【每页<font color="red"><?=$maxpage?></font>条记录】【共<font color="red"><?=$totalpage?></font>页】<input type="text" name="page" size="3" onKeyUp="IsDigit(this);">&nbsp;<input type="submit" value="GO"></td></form>
</tr>
  </table>
</center>
</BODY>
</HTML>

<script language="javascript">
function IsDigit(obj) 
{ 
if(obj.value.replace(/[\d+]/ig,"").length>0) { 
  alert('enter an number'); 
  document.getElementById(obj).value =""; 
} 
} 
</script>